<!doctype html>

<html>
<head>
  <link rel="shortcut icon" href="static/images/favicon.ico" type="image/x-icon">
  <title>hovercard.js (Closure Library API Documentation - JavaScript)</title>
  <link rel="stylesheet" href="static/css/base.css">
  <link rel="stylesheet" href="static/css/doc.css">
  <link rel="stylesheet" href="static/css/sidetree.css">
  <link rel="stylesheet" href="static/css/prettify.css">

  <script>
     var _staticFilePath = "static/";
     var _typeTreeName = "goog";
     var _fileTreeName = "Source";
  </script>

  <script src="static/js/doc.js">
  </script>


  <meta charset="utf8">
</head>

<body onload="grokdoc.onLoad();">

<div id="header">
  <div class="g-section g-tpl-50-50 g-split">
    <div class="g-unit g-first">
      <a id="logo" href="index.html">Closure Library API Documentation</a>
    </div>

    <div class="g-unit">
      <div class="g-c">
        <strong>Go to class or file:</strong>
        <input type="text" id="ac">
      </div>
    </div>
  </div>
</div>

<div class="clear"></div>

<h2><a href="closure_goog_ui_hovercard.js.html">hovercard.js</a></h2>

<pre class="prettyprint lang-js">
<a name="line1"></a>// Copyright 2008 The Closure Library Authors. All Rights Reserved.
<a name="line2"></a>//
<a name="line3"></a>// Licensed under the Apache License, Version 2.0 (the &quot;License&quot;);
<a name="line4"></a>// you may not use this file except in compliance with the License.
<a name="line5"></a>// You may obtain a copy of the License at
<a name="line6"></a>//
<a name="line7"></a>//      http://www.apache.org/licenses/LICENSE-2.0
<a name="line8"></a>//
<a name="line9"></a>// Unless required by applicable law or agreed to in writing, software
<a name="line10"></a>// distributed under the License is distributed on an &quot;AS-IS&quot; BASIS,
<a name="line11"></a>// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
<a name="line12"></a>// See the License for the specific language governing permissions and
<a name="line13"></a>// limitations under the License.
<a name="line14"></a>
<a name="line15"></a>/**
<a name="line16"></a> * @fileoverview Show hovercards with a delay after the mouse moves over an
<a name="line17"></a> * element of a specified type and with a specific attribute.
<a name="line18"></a> *
<a name="line19"></a> * @see ../demos/hovercard.html
<a name="line20"></a> */
<a name="line21"></a>
<a name="line22"></a>goog.provide(&#39;goog.ui.HoverCard&#39;);
<a name="line23"></a>goog.provide(&#39;goog.ui.HoverCard.EventType&#39;);
<a name="line24"></a>goog.provide(&#39;goog.ui.HoverCard.TriggerEvent&#39;);
<a name="line25"></a>
<a name="line26"></a>goog.require(&#39;goog.dom&#39;);
<a name="line27"></a>goog.require(&#39;goog.events&#39;);
<a name="line28"></a>goog.require(&#39;goog.events.EventType&#39;);
<a name="line29"></a>goog.require(&#39;goog.ui.AdvancedTooltip&#39;);
<a name="line30"></a>
<a name="line31"></a>
<a name="line32"></a>
<a name="line33"></a>/**
<a name="line34"></a> * Create a hover card object.  Hover cards extend tooltips in that they don&#39;t
<a name="line35"></a> * have to be manually attached to each element that can cause them to display.
<a name="line36"></a> * Instead, you can create a function that gets called when the mouse goes over
<a name="line37"></a> * any element on your page, and returns whether or not the hovercard should be
<a name="line38"></a> * shown for that element.
<a name="line39"></a> *
<a name="line40"></a> * Alternatively, you can define a map of tag names to the attribute name each
<a name="line41"></a> * tag should have for that tag to trigger the hover card.  See example below.
<a name="line42"></a> *
<a name="line43"></a> * Hovercards can also be triggered manually by calling
<a name="line44"></a> * {@code triggerForElement}, shown without a delay by calling
<a name="line45"></a> * {@code showForElement}, or triggered over other elements by calling
<a name="line46"></a> * {@code attach}.  For the latter two cases, the application is responsible
<a name="line47"></a> * for calling {@code detach} when finished.
<a name="line48"></a> *
<a name="line49"></a> * HoverCard objects fire a TRIGGER event when the mouse moves over an element
<a name="line50"></a> * that can trigger a hovercard, and BEFORE_SHOW when the hovercard is
<a name="line51"></a> * about to be shown.  Clients can respond to these events and can prevent the
<a name="line52"></a> * hovercard from being triggered or shown.
<a name="line53"></a> *
<a name="line54"></a> * @param {Function|Object} isAnchor Function that returns true if a given
<a name="line55"></a> *     element should trigger the hovercard.  Alternatively, it can be a map of
<a name="line56"></a> *     tag names to the attribute that the tag should have in order to trigger
<a name="line57"></a> *     the hovercard, e.g., {A: &#39;href&#39;} for all links.  Tag names must be all
<a name="line58"></a> *     upper case; attribute names are case insensitive.
<a name="line59"></a> * @param {boolean=} opt_checkDescendants Use false for a performance gain if
<a name="line60"></a> *     you are sure that none of your triggering elements have child elements.
<a name="line61"></a> *     Default is true.
<a name="line62"></a> * @param {goog.dom.DomHelper=} opt_domHelper Optional DOM helper to use for
<a name="line63"></a> *     creating and rendering the hovercard element.
<a name="line64"></a> * @param {Document=} opt_triggeringDocument Optional document to use in place
<a name="line65"></a> *     of the one included in the DomHelper for finding triggering elements.
<a name="line66"></a> *     Defaults to the document included in the DomHelper.
<a name="line67"></a> * @constructor
<a name="line68"></a> * @extends {goog.ui.AdvancedTooltip}
<a name="line69"></a> */
<a name="line70"></a>goog.ui.HoverCard = function(isAnchor, opt_checkDescendants, opt_domHelper,
<a name="line71"></a>    opt_triggeringDocument) {
<a name="line72"></a>  goog.ui.AdvancedTooltip.call(this, null, null, opt_domHelper);
<a name="line73"></a>
<a name="line74"></a>  if (goog.isFunction(isAnchor)) {
<a name="line75"></a>    // Override default implementation of {@code isAnchor_}.
<a name="line76"></a>    this.isAnchor_ = isAnchor;
<a name="line77"></a>  } else {
<a name="line78"></a>
<a name="line79"></a>    /**
<a name="line80"></a>     * Map of tag names to attribute names that will trigger a hovercard.
<a name="line81"></a>     * @type {Object}
<a name="line82"></a>     * @private
<a name="line83"></a>     */
<a name="line84"></a>    this.anchors_ = isAnchor;
<a name="line85"></a>  }
<a name="line86"></a>
<a name="line87"></a>  /**
<a name="line88"></a>   * Whether anchors may have child elements.  If true, then we need to check
<a name="line89"></a>   * the parent chain of any mouse over event to see if any of those elements
<a name="line90"></a>   * could be anchors.  Default is true.
<a name="line91"></a>   * @type {boolean}
<a name="line92"></a>   * @private
<a name="line93"></a>   */
<a name="line94"></a>  this.checkDescendants_ = opt_checkDescendants != false;
<a name="line95"></a>
<a name="line96"></a>  /**
<a name="line97"></a>   * Array of anchor elements that should be detached when we are no longer
<a name="line98"></a>   * associated with them.
<a name="line99"></a>   * @type {!Array.&lt;Element&gt;}
<a name="line100"></a>   * @private
<a name="line101"></a>   */
<a name="line102"></a>  this.tempAttachedAnchors_ = [];
<a name="line103"></a>
<a name="line104"></a>  /**
<a name="line105"></a>   * Document containing the triggering elements, to which we listen for
<a name="line106"></a>   * mouseover events.
<a name="line107"></a>   * @type {Document}
<a name="line108"></a>   * @private
<a name="line109"></a>   */
<a name="line110"></a>  this.document_ = opt_triggeringDocument || (opt_domHelper ?
<a name="line111"></a>      opt_domHelper.getDocument() : goog.dom.getDocument());
<a name="line112"></a>
<a name="line113"></a>  goog.events.listen(this.document_, goog.events.EventType.MOUSEOVER,
<a name="line114"></a>                     this.handleTriggerMouseOver_, false, this);
<a name="line115"></a>};
<a name="line116"></a>goog.inherits(goog.ui.HoverCard, goog.ui.AdvancedTooltip);
<a name="line117"></a>
<a name="line118"></a>
<a name="line119"></a>/**
<a name="line120"></a> * Enum for event type fired by HoverCard.
<a name="line121"></a> * @enum {string}
<a name="line122"></a> */
<a name="line123"></a>goog.ui.HoverCard.EventType = {
<a name="line124"></a>  TRIGGER: &#39;trigger&#39;,
<a name="line125"></a>  CANCEL_TRIGGER: &#39;canceltrigger&#39;,
<a name="line126"></a>  BEFORE_SHOW: goog.ui.PopupBase.EventType.BEFORE_SHOW,
<a name="line127"></a>  SHOW: goog.ui.PopupBase.EventType.SHOW,
<a name="line128"></a>  BEFORE_HIDE: goog.ui.PopupBase.EventType.BEFORE_HIDE,
<a name="line129"></a>  HIDE: goog.ui.PopupBase.EventType.HIDE
<a name="line130"></a>};
<a name="line131"></a>
<a name="line132"></a>
<a name="line133"></a>/** @override */
<a name="line134"></a>goog.ui.HoverCard.prototype.disposeInternal = function() {
<a name="line135"></a>  goog.ui.HoverCard.superClass_.disposeInternal.call(this);
<a name="line136"></a>
<a name="line137"></a>  goog.events.unlisten(this.document_, goog.events.EventType.MOUSEOVER,
<a name="line138"></a>                       this.handleTriggerMouseOver_, false, this);
<a name="line139"></a>};
<a name="line140"></a>
<a name="line141"></a>
<a name="line142"></a>/**
<a name="line143"></a> * Anchor of hovercard currently being shown.  This may be different from
<a name="line144"></a> * {@code anchor} property if a second hovercard is triggered, when
<a name="line145"></a> * {@code anchor} becomes the second hovercard while {@code currentAnchor_}
<a name="line146"></a> * is still the old (but currently displayed) anchor.
<a name="line147"></a> * @type {Element}
<a name="line148"></a> * @private
<a name="line149"></a> */
<a name="line150"></a>goog.ui.HoverCard.prototype.currentAnchor_;
<a name="line151"></a>
<a name="line152"></a>
<a name="line153"></a>/**
<a name="line154"></a> * Maximum number of levels to search up the dom when checking descendants.
<a name="line155"></a> * @type {number}
<a name="line156"></a> * @private
<a name="line157"></a> */
<a name="line158"></a>goog.ui.HoverCard.prototype.maxSearchSteps_;
<a name="line159"></a>
<a name="line160"></a>
<a name="line161"></a>/**
<a name="line162"></a> * This function can be overridden by passing a function as the first parameter
<a name="line163"></a> * to the constructor.
<a name="line164"></a> * @param {Node} node Node to test.
<a name="line165"></a> * @return {boolean} Whether or not hovercard should be shown.
<a name="line166"></a> * @private
<a name="line167"></a> */
<a name="line168"></a>goog.ui.HoverCard.prototype.isAnchor_ = function(node) {
<a name="line169"></a>  return node.tagName in this.anchors_ &amp;&amp;
<a name="line170"></a>      !!node.getAttribute(this.anchors_[node.tagName]);
<a name="line171"></a>};
<a name="line172"></a>
<a name="line173"></a>
<a name="line174"></a>/**
<a name="line175"></a> * If the user mouses over an element with the correct tag and attribute, then
<a name="line176"></a> * trigger the hovercard for that element.  If anchors could have children, then
<a name="line177"></a> * we also need to check the parent chain of the given element.
<a name="line178"></a> * @param {goog.events.Event} e Mouse over event.
<a name="line179"></a> * @private
<a name="line180"></a> */
<a name="line181"></a>goog.ui.HoverCard.prototype.handleTriggerMouseOver_ = function(e) {
<a name="line182"></a>  var target = /** @type {Element} */ (e.target);
<a name="line183"></a>  // Target might be null when hovering over disabled input textboxes in IE.
<a name="line184"></a>  if (!target) {
<a name="line185"></a>    return;
<a name="line186"></a>  }
<a name="line187"></a>  if (this.isAnchor_(target)) {
<a name="line188"></a>    this.setPosition(null);
<a name="line189"></a>    this.triggerForElement(target);
<a name="line190"></a>  } else if (this.checkDescendants_) {
<a name="line191"></a>    var trigger = goog.dom.getAncestor(target,
<a name="line192"></a>                                       goog.bind(this.isAnchor_, this),
<a name="line193"></a>                                       false,
<a name="line194"></a>                                       this.maxSearchSteps_);
<a name="line195"></a>    if (trigger) {
<a name="line196"></a>      this.setPosition(null);
<a name="line197"></a>      this.triggerForElement(/** @type {Element} */ (trigger));
<a name="line198"></a>    }
<a name="line199"></a>  }
<a name="line200"></a>};
<a name="line201"></a>
<a name="line202"></a>
<a name="line203"></a>/**
<a name="line204"></a> * Triggers the hovercard to show after a delay.
<a name="line205"></a> * @param {Element} anchorElement Element that is triggering the hovercard.
<a name="line206"></a> * @param {goog.positioning.AbstractPosition=} opt_pos Position to display
<a name="line207"></a> *     hovercard.
<a name="line208"></a> * @param {Object=} opt_data Data to pass to the onTrigger event.
<a name="line209"></a> */
<a name="line210"></a>goog.ui.HoverCard.prototype.triggerForElement = function(anchorElement,
<a name="line211"></a>                                                         opt_pos, opt_data) {
<a name="line212"></a>  if (anchorElement == this.currentAnchor_) {
<a name="line213"></a>    // Element is already showing, just make sure it doesn&#39;t hide.
<a name="line214"></a>    this.clearHideTimer();
<a name="line215"></a>    return;
<a name="line216"></a>  }
<a name="line217"></a>  if (anchorElement == this.anchor) {
<a name="line218"></a>    // Hovercard is pending, no need to retrigger.
<a name="line219"></a>    return;
<a name="line220"></a>  }
<a name="line221"></a>
<a name="line222"></a>  // If a previous hovercard was being triggered, cancel it.
<a name="line223"></a>  this.maybeCancelTrigger_();
<a name="line224"></a>
<a name="line225"></a>  // Create a new event for this trigger
<a name="line226"></a>  var triggerEvent = new goog.ui.HoverCard.TriggerEvent(
<a name="line227"></a>      goog.ui.HoverCard.EventType.TRIGGER, this, anchorElement, opt_data);
<a name="line228"></a>
<a name="line229"></a>  if (!this.getElements().contains(anchorElement)) {
<a name="line230"></a>    this.attach(anchorElement);
<a name="line231"></a>    this.tempAttachedAnchors_.push(anchorElement);
<a name="line232"></a>  }
<a name="line233"></a>  this.anchor = anchorElement;
<a name="line234"></a>  if (!this.onTrigger(triggerEvent)) {
<a name="line235"></a>    this.onCancelTrigger();
<a name="line236"></a>    return;
<a name="line237"></a>  }
<a name="line238"></a>  var pos = opt_pos || this.position_;
<a name="line239"></a>  this.startShowTimer(anchorElement,
<a name="line240"></a>      /** @type {goog.positioning.AbstractPosition} */ (pos));
<a name="line241"></a>};
<a name="line242"></a>
<a name="line243"></a>
<a name="line244"></a>/**
<a name="line245"></a> * Sets the current anchor element at the time that the hovercard is shown.
<a name="line246"></a> * @param {Element} anchor New current anchor element, or null if there is
<a name="line247"></a> *     no current anchor.
<a name="line248"></a> * @private
<a name="line249"></a> */
<a name="line250"></a>goog.ui.HoverCard.prototype.setCurrentAnchor_ = function(anchor) {
<a name="line251"></a>  if (anchor != this.currentAnchor_) {
<a name="line252"></a>    this.detachTempAnchor_(this.currentAnchor_);
<a name="line253"></a>  }
<a name="line254"></a>  this.currentAnchor_ = anchor;
<a name="line255"></a>};
<a name="line256"></a>
<a name="line257"></a>
<a name="line258"></a>/**
<a name="line259"></a> * If given anchor is in the list of temporarily attached anchors, then
<a name="line260"></a> * detach and remove from the list.
<a name="line261"></a> * @param {Element|undefined} anchor Anchor element that we may want to detach
<a name="line262"></a> *     from.
<a name="line263"></a> * @private
<a name="line264"></a> */
<a name="line265"></a>goog.ui.HoverCard.prototype.detachTempAnchor_ = function(anchor) {
<a name="line266"></a>  var pos = goog.array.indexOf(this.tempAttachedAnchors_, anchor);
<a name="line267"></a>  if (pos != -1) {
<a name="line268"></a>    this.detach(anchor);
<a name="line269"></a>    this.tempAttachedAnchors_.splice(pos, 1);
<a name="line270"></a>  }
<a name="line271"></a>};
<a name="line272"></a>
<a name="line273"></a>
<a name="line274"></a>/**
<a name="line275"></a> * Called when an element triggers the hovercard.  This will return false
<a name="line276"></a> * if an event handler sets preventDefault to true, which will prevent
<a name="line277"></a> * the hovercard from being shown.
<a name="line278"></a> * @param {!goog.ui.HoverCard.TriggerEvent} triggerEvent Event object to use
<a name="line279"></a> *     for trigger event.
<a name="line280"></a> * @return {boolean} Whether hovercard should be shown or cancelled.
<a name="line281"></a> * @protected
<a name="line282"></a> */
<a name="line283"></a>goog.ui.HoverCard.prototype.onTrigger = function(triggerEvent) {
<a name="line284"></a>  return this.dispatchEvent(triggerEvent);
<a name="line285"></a>};
<a name="line286"></a>
<a name="line287"></a>
<a name="line288"></a>/**
<a name="line289"></a> * Abort pending hovercard showing, if any.
<a name="line290"></a> */
<a name="line291"></a>goog.ui.HoverCard.prototype.cancelTrigger = function() {
<a name="line292"></a>  this.clearShowTimer();
<a name="line293"></a>  this.onCancelTrigger();
<a name="line294"></a>};
<a name="line295"></a>
<a name="line296"></a>
<a name="line297"></a>/**
<a name="line298"></a> * If hovercard is in the process of being triggered, then cancel it.
<a name="line299"></a> * @private
<a name="line300"></a> */
<a name="line301"></a>goog.ui.HoverCard.prototype.maybeCancelTrigger_ = function() {
<a name="line302"></a>  if (this.getState() == goog.ui.Tooltip.State.WAITING_TO_SHOW ||
<a name="line303"></a>      this.getState() == goog.ui.Tooltip.State.UPDATING) {
<a name="line304"></a>    this.cancelTrigger();
<a name="line305"></a>  }
<a name="line306"></a>};
<a name="line307"></a>
<a name="line308"></a>
<a name="line309"></a>/**
<a name="line310"></a> * This method gets called when we detect that a trigger event will not lead
<a name="line311"></a> * to the hovercard being shown.
<a name="line312"></a> * @protected
<a name="line313"></a> */
<a name="line314"></a>goog.ui.HoverCard.prototype.onCancelTrigger = function() {
<a name="line315"></a>  var event = new goog.ui.HoverCard.TriggerEvent(
<a name="line316"></a>      goog.ui.HoverCard.EventType.CANCEL_TRIGGER, this, this.anchor || null);
<a name="line317"></a>  this.dispatchEvent(event);
<a name="line318"></a>  this.detachTempAnchor_(this.anchor);
<a name="line319"></a>  delete this.anchor;
<a name="line320"></a>};
<a name="line321"></a>
<a name="line322"></a>
<a name="line323"></a>/**
<a name="line324"></a> * Gets the DOM element that triggered the current hovercard.  Note that in
<a name="line325"></a> * the TRIGGER or CANCEL_TRIGGER events, the current hovercard&#39;s anchor may not
<a name="line326"></a> * be the one that caused the event, so use the event&#39;s anchor property instead.
<a name="line327"></a> * @return {Element} Object that caused the currently displayed hovercard (or
<a name="line328"></a> *     pending hovercard if none is displayed) to be triggered.
<a name="line329"></a> */
<a name="line330"></a>goog.ui.HoverCard.prototype.getAnchorElement = function() {
<a name="line331"></a>  // this.currentAnchor_ is only set if the hovercard is showing.  If it isn&#39;t
<a name="line332"></a>  // showing yet, then use this.anchor as the pending anchor.
<a name="line333"></a>  return /** @type {Element} */ (this.currentAnchor_ || this.anchor);
<a name="line334"></a>};
<a name="line335"></a>
<a name="line336"></a>
<a name="line337"></a>/**
<a name="line338"></a> * Make sure we detach from temp anchor when we are done displaying hovercard.
<a name="line339"></a> * @protected
<a name="line340"></a> * @suppress {underscore}
<a name="line341"></a> * @override
<a name="line342"></a> */
<a name="line343"></a>goog.ui.HoverCard.prototype.onHide_ = function() {
<a name="line344"></a>  goog.ui.HoverCard.superClass_.onHide_.call(this);
<a name="line345"></a>  this.setCurrentAnchor_(null);
<a name="line346"></a>};
<a name="line347"></a>
<a name="line348"></a>
<a name="line349"></a>/**
<a name="line350"></a> * This mouse over event is only received if the anchor is already attached.
<a name="line351"></a> * If it was attached manually, then it may need to be triggered.
<a name="line352"></a> * @param {goog.events.BrowserEvent} event Mouse over event.
<a name="line353"></a> * @override
<a name="line354"></a> */
<a name="line355"></a>goog.ui.HoverCard.prototype.handleMouseOver = function(event) {
<a name="line356"></a>  // If this is a child of a triggering element, find the triggering element.
<a name="line357"></a>  var trigger = this.getAnchorFromElement(
<a name="line358"></a>      /** @type {Element} */ (event.target));
<a name="line359"></a>
<a name="line360"></a>  // If we moused over an element different from the one currently being
<a name="line361"></a>  // triggered (if any), then trigger this new element.
<a name="line362"></a>  if (trigger &amp;&amp; trigger != this.anchor) {
<a name="line363"></a>    this.triggerForElement(trigger);
<a name="line364"></a>    return;
<a name="line365"></a>  }
<a name="line366"></a>
<a name="line367"></a>  goog.ui.HoverCard.superClass_.handleMouseOver.call(this, event);
<a name="line368"></a>};
<a name="line369"></a>
<a name="line370"></a>
<a name="line371"></a>/**
<a name="line372"></a> * If the mouse moves out of the trigger while we&#39;re being triggered, then
<a name="line373"></a> * cancel it.
<a name="line374"></a> * @param {goog.events.BrowserEvent} event Mouse out or blur event.
<a name="line375"></a> * @override
<a name="line376"></a> */
<a name="line377"></a>goog.ui.HoverCard.prototype.handleMouseOutAndBlur = function(event) {
<a name="line378"></a>  // Get ready to see if a trigger should be cancelled.
<a name="line379"></a>  var anchor = this.anchor;
<a name="line380"></a>  var state = this.getState();
<a name="line381"></a>  goog.ui.HoverCard.superClass_.handleMouseOutAndBlur.call(this, event);
<a name="line382"></a>  if (state != this.getState() &amp;&amp;
<a name="line383"></a>      (state == goog.ui.Tooltip.State.WAITING_TO_SHOW ||
<a name="line384"></a>       state == goog.ui.Tooltip.State.UPDATING)) {
<a name="line385"></a>    // Tooltip&#39;s handleMouseOutAndBlur method sets anchor to null.  Reset
<a name="line386"></a>    // so that the cancel trigger event will have the right data, and so that
<a name="line387"></a>    // it will be properly detached.
<a name="line388"></a>    this.anchor = anchor;
<a name="line389"></a>    this.onCancelTrigger();  // This will remove and detach the anchor.
<a name="line390"></a>  }
<a name="line391"></a>};
<a name="line392"></a>
<a name="line393"></a>
<a name="line394"></a>/**
<a name="line395"></a> * Called by timer from mouse over handler. If this is called and the hovercard
<a name="line396"></a> * is not shown for whatever reason, then send a cancel trigger event.
<a name="line397"></a> * @param {Element} el Element to show tooltip for.
<a name="line398"></a> * @param {goog.positioning.AbstractPosition=} opt_pos Position to display popup
<a name="line399"></a> *     at.
<a name="line400"></a> * @override
<a name="line401"></a> */
<a name="line402"></a>goog.ui.HoverCard.prototype.maybeShow = function(el, opt_pos) {
<a name="line403"></a>  goog.ui.HoverCard.superClass_.maybeShow.call(this, el, opt_pos);
<a name="line404"></a>
<a name="line405"></a>  if (!this.isVisible()) {
<a name="line406"></a>    this.cancelTrigger();
<a name="line407"></a>  } else {
<a name="line408"></a>    this.setCurrentAnchor_(el);
<a name="line409"></a>  }
<a name="line410"></a>};
<a name="line411"></a>
<a name="line412"></a>
<a name="line413"></a>/**
<a name="line414"></a> * Sets the max number of levels to search up the dom if checking descendants.
<a name="line415"></a> * @param {number} maxSearchSteps Maximum number of levels to search up the
<a name="line416"></a> *     dom if checking descendants.
<a name="line417"></a> */
<a name="line418"></a>goog.ui.HoverCard.prototype.setMaxSearchSteps = function(maxSearchSteps) {
<a name="line419"></a>  if (!maxSearchSteps) {
<a name="line420"></a>    this.checkDescendants_ = false;
<a name="line421"></a>  } else if (this.checkDescendants_) {
<a name="line422"></a>    this.maxSearchSteps_ = maxSearchSteps;
<a name="line423"></a>  }
<a name="line424"></a>};
<a name="line425"></a>
<a name="line426"></a>
<a name="line427"></a>
<a name="line428"></a>/**
<a name="line429"></a> * Create a trigger event for specified anchor and optional data.
<a name="line430"></a> * @param {goog.ui.HoverCard.EventType} type Event type.
<a name="line431"></a> * @param {goog.ui.HoverCard} target Hovercard that is triggering the event.
<a name="line432"></a> * @param {Element} anchor Element that triggered event.
<a name="line433"></a> * @param {Object=} opt_data Optional data to be available in the TRIGGER event.
<a name="line434"></a> * @constructor
<a name="line435"></a> * @extends {goog.events.Event}
<a name="line436"></a> */
<a name="line437"></a>goog.ui.HoverCard.TriggerEvent = function(type, target, anchor, opt_data) {
<a name="line438"></a>  goog.events.Event.call(this, type, target);
<a name="line439"></a>
<a name="line440"></a>  /**
<a name="line441"></a>   * Element that triggered the hovercard event.
<a name="line442"></a>   * @type {Element}
<a name="line443"></a>   */
<a name="line444"></a>  this.anchor = anchor;
<a name="line445"></a>
<a name="line446"></a>  /**
<a name="line447"></a>   * Optional data to be passed to the listener.
<a name="line448"></a>   * @type {Object|undefined}
<a name="line449"></a>   */
<a name="line450"></a>  this.data = opt_data;
<a name="line451"></a>};
<a name="line452"></a>goog.inherits(goog.ui.HoverCard.TriggerEvent, goog.events.Event);
</pre>


</body>
</html>
